package com.woniuxy.dudugua.service.impl;

import com.woniuxy.dudugua.entity.Aiface;
import com.woniuxy.dudugua.entity.AifaceExample;
import com.woniuxy.dudugua.mapper.AifaceMapper;
import com.woniuxy.dudugua.mapper.StoreMapper;
import com.woniuxy.dudugua.service.AIFaceService;
import com.woniuxy.dudugua.util.view.StoreNavBar;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;

@Service
public class AIFaceServiceImpl implements AIFaceService {
    @Autowired
    private AifaceMapper aifaceMapper;
    @Autowired
    private StoreMapper storeMapper;
    @Override
    public Aiface selectById(int id) {
        Aiface aiface = aifaceMapper.selectByPrimaryKey(id);
        return aiface;
    }

    @Override
    public int insert(Aiface aiface) {
        int insert = aifaceMapper.insert(aiface);
        return insert;
    }

    @Override
    public List<Aiface> selectListById(int id) {
        AifaceExample e = new AifaceExample();
        AifaceExample.Criteria c = e.createCriteria();
        c.andUserIdEqualTo(id);
        e.setOrderByClause("add_time desc");
        List<Aiface> list = aifaceMapper.selectByExample(e);
        return list;
    }

    @Override
    public List<StoreNavBar> selectAIProduct(String example) {
        HashMap<String, Object> map = new HashMap();
        map.put("example",example);
        List list = storeMapper.getAIFaceProductByExmpel(map);
        return list;
    }
}
